package com.example.a313ldy.yuejian_17.Fragment.IndexFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.a313ldy.yuejian_17.Adapter.ContestAdapter;
import com.example.a313ldy.yuejian_17.Bean.Contest;
import com.example.a313ldy.yuejian_17.Listener.ContestListener;
import com.example.a313ldy.yuejian_17.Model.ContestModel;
import com.example.a313ldy.yuejian_17.R;

import java.util.List;

/**
 * Created by LDY on 2017/10/9.
 */

public class ContestFragment extends Fragment implements ContestListener<Contest> {


    RecyclerView recyclerView_Contestlist;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View  v = inflater.inflate(R.layout.fragment_contest,null);
        recyclerView_Contestlist = (RecyclerView) v.findViewById(R.id.id_fragment_main);
        recyclerView_Contestlist.setLayoutManager(new LinearLayoutManager(getActivity()));


        ContestModel ContestModel = new ContestModel();
        ContestModel.ContestData(this);
        return v;
    }




    @Override
    public void onResponse(Contest Contest) {
        List<Contest.RacelistEntity> RacelistEntity = Contest.getRacelist();
        System.out.println("+++++" + RacelistEntity);
        ContestAdapter adapter = new ContestAdapter(getContext(), RacelistEntity);
        recyclerView_Contestlist.setAdapter(adapter);
    }

    @Override
    public void onFail(String msg) {
        System.out.println("+++++" + "失败率");
    }



}
